package com.lhd.ivos.geofence.controller;

import com.lhd.ivos.base.response.JsonResult;
import com.lhd.ivos.geofence.pojo.dto.GeofenceParam;
import com.lhd.ivos.geofence.pojo.dto.GeofenceQuery;
import com.lhd.ivos.geofence.pojo.vo.GeofenceVO;
import com.lhd.ivos.geofence.service.GeofenceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author lhd
 * date 2024/5/23
 * @apiNote
 */
@Slf4j
@RestController
@RequestMapping("/v1/geofence")
public class GeofenceController {

    @Autowired
    GeofenceService geofenceService;

    @GetMapping("/select")
    public JsonResult selectGeofence(GeofenceQuery geofenceQuery){
        log.debug("查询围栏:", geofenceQuery);
        List<GeofenceVO> list = geofenceService.selectGeofence(geofenceQuery);
        return JsonResult.ok(list);
    }

    @PostMapping("/save")
    public JsonResult save(GeofenceParam geofenceParam){
        log.debug("保存围栏的信息为:", geofenceParam);
        geofenceService.saveGeofence(geofenceParam);
        return JsonResult.ok();
    }


    @PostMapping("/delete/{id}")
    public JsonResult delete(@PathVariable Long id){
        log.debug("删除围栏:", id);
        geofenceService.deleteGeofenceById(id);
        return JsonResult.ok();
    }


}
